package com.qzsoft.zhjd.cement.modules.videomonitor.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.qzsoft.jeemis.common.utils.Result;
import com.qzsoft.zhjd.common.utils.ResultUtils;
import com.qzsoft.zhjd.cement.modules.videomonitor.service.CementVideoMonitorService;
import com.qzsoft.zhjd.monitoring.enums.VideoMonitorEnums;
import com.qzsoft.zhjd.monitoring.modules.videomonitor.dto.StreamInfoDto;
import com.qzsoft.zhjd.monitoring.modules.videomonitor.dto.VideoMonitorTreeDto;
import com.qzsoft.zhjd.monitoring.modules.videomonitor.entity.VideoMonitorEntity;
import com.qzsoft.zhjd.monitoring.modules.videomonitor.service.VideoMonitorService;

/**
 * @ClassName CementVideoMonitorController
 * @Description 水稳视频监控
 * @author linhuawei
 * @since 2022-03-23
 */
@RestController
@RequestMapping("/api/cementVideoMonitor")
public class CementVideoMonitorController {

    @Autowired
    private CementVideoMonitorService cementVideoMonitorService;

    @Autowired
    private VideoMonitorService videoMonitorService;

    /**
     * @Title tree
     * @Description 获取视频树(基地获取水稳拌合楼)
     * @return 视频树
     */
    @GetMapping("/tree")
    public Result<List<VideoMonitorTreeDto>> tree() {
        List<VideoMonitorTreeDto> list = cementVideoMonitorService.tree();
        return ResultUtils.ok(list);
    }

    /**
     * @Title list
     * @Description 获取水稳拌合楼摄像头列表
     * @return
     */
    @GetMapping("/list")
    public Result<List<VideoMonitorEntity>> list(@RequestParam(required = true) String resourceId) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("resourceId", resourceId);
        params.put("resourceType", VideoMonitorEnums.cement.name());
        List<VideoMonitorEntity> list = videoMonitorService.list(params);
        return ResultUtils.ok(list);
    }

    /**
     * @Title getStreamInfo
     * @Description 获取播放信息
     * @param app
     * @param stream
     * @return
     */
    @GetMapping("/getStreamInfo")
    public Result<StreamInfoDto> getStreamInfo(@RequestParam(required = true) String app,
            @RequestParam(required = true) String stream) {
        StreamInfoDto data = videoMonitorService.getStreamInfo(app, stream, VideoMonitorEnums.cement.name());
        return ResultUtils.ok(data);
    }

}
